﻿//3D Visualizer
namespace Diplom.Graphics.D3D
{
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using Diplom.Graphics.D3D;
    using Diplom.Graphics.D3D.Helpers;
    using Diplom.NumericArrays;

    public static class ColorVisualizer
    {
        public static void DrawGraphic(ref System.Drawing.Graphics canvas, System.Drawing.RectangleF workRect, ref NumericArrays.Numeric2DArray Sab, int CountIso)
        {
            Bitmap btm = new Bitmap(Sab.MSize, Sab.NSize);
            
            double min = Sab.Min;
            double max = Sab.Max;
            for (int i = 0; i < Sab.NSize; i++)
            {
                for (int j = 0; j < Sab.MSize; j++)
                {
                    int colorInd = (int)((Sab.Items[i][j]-min)*CountIso/(max-min));
                    btm.SetPixel(j, i, GenerateColor.GetColor(CountIso, colorInd));
                }
            }
            canvas.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            canvas.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            canvas.DrawImage(btm, workRect);
        }
    }
}
